package com.cr.front.news.service.impl;

import com.cr.front.news.dao.mapper.NewsMapper;
import com.cr.front.news.dao.repository.NewsRepository;
import com.cr.front.news.pojo.entity.News;
import com.cr.front.news.pojo.query.SearchParam;
import com.cr.front.news.pojo.vo.NewsByCategoryIdVO;
import com.cr.front.news.pojo.vo.NewsByTimeVO;
import com.cr.front.news.pojo.vo.NewsByViewsVO;
import com.cr.front.news.pojo.vo.NewsVO;
import com.cr.front.news.service.NewsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {

    private static final Logger log = LoggerFactory.getLogger(NewsServiceImpl.class);
    @Autowired
    private NewsRepository newsRepository;



    @Override
    public List<NewsByTimeVO> getLatestNews() {
        return newsRepository.getNewsByTimeRank();
    }

    @Override
    public NewsVO getDetailNews(Integer id) {
        return newsRepository.getDetailNewsById(id);
    }

    @Override
    public List<NewsByViewsVO> getNewsByViews() {
        return newsRepository.getNewsByViews();
    }

    @Override
    public List<News> getTotalNewsByCategoryId(SearchParam searchParam) {
        return newsRepository.getNewsByCategoryId(searchParam);
    }

    @Override
    public List<News> cacheNews() {
        return newsRepository.getCacheNews();
    }


}
